import { formatHeader } from 'plugins/utils.js'

export function filterSuccess (state, payload) {
  let res = JSON.parse(payload)
  state.status.items = res.status
  state.type.items = res.type
  state.env.items = res.env
  state.clouds.items = res.clouds
  state.re_per.items = res.re_per
}

export function headerSuccess (state, payload) {
  let header = JSON.parse(payload)
  state.columns = formatHeader(header)
  state.columns.splice(15, 0, {name: 'prjname', label: '关联项目', field: 'prjname'})
  state.columns.splice(16, 0, {name: 'srvname', label: '关联服务', field: 'srvname'})
  state.columns.splice(17, 0, {name: 'version', label: '运行版本', field: 'version'})
}

export function loadTableSuccess (state, payload) {
  state.tableData = payload.results
  state.serverPagination.rowsNumber = payload.count
  state.loading = false
}
